<template>
  <div class="risk-assessment-template">
    <t-space direction="vertical" style="width: 100%">
      <dashboard-box :options="dashboardOptions" :title="title"> </dashboard-box>
      <card title="风险治理">
        <governance-content />
      </card>
    </t-space>
  </div>
</template>
<script>
import Card from '@/components/Card/index.vue';
import DashboardBox from '@/components/DashboardBox/index.vue';
import GovernanceContent from './components/GovernanceContent.vue';
import { getUserToDOList } from '@/service/risk-assessment/governance';

export default {
  name: 'riskAssessmentGovernance',
  components: { Card, DashboardBox, GovernanceContent },
  data() {
    return {
      title: '我的待办',
      dashboardOptions: [
        {
          count: 0,
          title: '风险待办',
        },
        {
          count: 0,
          title: '待处置',
        },
        {
          count: 0,
          title: '待审核',
        },
        {
          count: 0,
          title: '已过期',
        },
      ],
    };
  },
  mounted() {
    this.getTodoList();
    this.$bus.$on('updateDashboard', () => {
      this.getTodoList();
    });
  },
  methods: {
    async getTodoList() {
      const res = await getUserToDOList();
      const { taskCount, pendDisposal, pendReview, expired } = res.data;
      this.dashboardOptions[0].count = taskCount;
      this.dashboardOptions[1].count = pendDisposal;
      this.dashboardOptions[2].count = pendReview;
      this.dashboardOptions[3].count = expired;
    },
  },
};
</script>
